package wwk.com.android_meilishuo.mvp.presenter;

import android.content.Context;

import com.wwk.core.mvp.presenter.PresenterBase;

import java.util.List;

import wwk.com.android_meilishuo.mvp.model.MLSModel;
import wwk.com.android_meilishuo.mvp.model.SecondFloorBiz;
import wwk.com.android_meilishuo.mvp.view.MLSView;
import wwk.com.android_meilishuo.ui.secondfloor.DataBean;
import wwk.com.android_meilishuo.ui.secondfloor.EmptyLayout;
import wwk.com.android_meilishuo.ui.secondfloor.MyVerticalViewPagerAdapter;
import wwk.com.android_meilishuo.ui.secondfloor.SecondFloorActivity;

/**
 * Created by Administrator on 2016/12/28.
 */

public class SFPresenter {
    private MLSModel.ISecondFloorBiz iSecondFloorBiz;
    private MLSView.ISecondFloorView iSecondFloorView;

    public SFPresenter(MLSView.ISecondFloorView iSecondFloorView) {
        this.iSecondFloorView = iSecondFloorView;
        this.iSecondFloorBiz = new SecondFloorBiz();
    }

    /**
     * 数据加载
     *
     * @param mContext
     */
    public void loadSFData(final Context mContext, final EmptyLayout sf_EmptyLayout) {
        iSecondFloorBiz.loadSecondFloorData(new MLSModel.OnSecondFloorListener() {
            @Override
            public void onSuccess(List<DataBean> list) {
                if (list != null && list.size() != 0) {
                    MyVerticalViewPagerAdapter adapter = new MyVerticalViewPagerAdapter(list, mContext);
                    if (adapter != null) {
                        iSecondFloorView.toSetAdapter(adapter);
                        sf_EmptyLayout.setErrorType(EmptyLayout.HIDE_LAYOUT);
                    }
                }
            }

            @Override
            public void onFailed(Exception e) {
                iSecondFloorView.showError(e);
            }
        }, mContext, sf_EmptyLayout);

    }
}
